package com.szbber.medical.door.viewModel

import android.content.Context
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.orhanobut.logger.Logger
import com.szbber.commen.api.Repository
import com.szbber.commen.api.launch
import com.szbber.commen.base.BaseViewModel
import com.szbber.commen.bean.DoorPatientBean
import com.szbber.commen.bean.RoomBean
import com.szbber.commen.utils.dataStoreRead

class HomeActivityVM:BaseViewModel() {



    val doorPatient = MutableLiveData<DoorPatientBean>()
    val doorName = MutableLiveData<RoomBean.Data>()
    fun getDoorPatient(context: Context?)= launch{
      val roomCode =   dataStoreRead<String>("roomCode")
       val queue = arrayOf("roomCode","xhsq1216")
        doorPatient.value = Repository.getDoorPatient(context, *queue)
    }

    fun  getDoorName()= launch {
        val dataStr = dataStoreRead<String>("RoomInfo")
        doorName.value = Gson().fromJson<RoomBean.Data>(dataStr, RoomBean.Data::class.java)
        Logger.e( Gson().toJson(doorName.value) )

    }
}